package com.dyit.springcloud.hospital.doctor.service.imlp;

import com.dyit.springcloud.hospital.doctor.dao.IDoctorDao;
import com.dyit.springcloud.hospital.domain.entity.Dept;
import com.dyit.springcloud.hospital.domain.entity.Doctor;
import com.dyit.springcloud.hospital.doctor.service.IDoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DoctorServiceImpl implements IDoctorService {

    @Autowired
    private IDoctorDao idd;


    @Override
    public void add(Doctor doctor) {
        idd.save(doctor);
    }

    @Override
    public void deleteDoctorById(int id) {
        idd.deleteDoctorById(id);
    }

    @Override
    public void update(Doctor doctor) {
        idd.save(doctor);
    }


    @Override
    public List<Doctor> findAll() {
        List all = idd.findAll();
        return all;
    }

    @Override
    public List<Doctor> findDoctorsByDept(Dept dept) {
        List<Doctor> doctors = idd.findDoctorsByDept(dept);

        return doctors;
    }

    @Override
    public Doctor findDoctorByName(String name) {
        Doctor doctor = idd.findDoctorByName(name);
        return doctor;
    }
}
